﻿using Avalonia.Controls;
using Avalonia.Interactivity;
using Avalonia.Markup.Xaml;
using GitNet.WindowsApp.Controls;
using GitNet.WindowsApp.Models;

namespace GitNet.WindowsApp.Views;

public partial class FolderView : UserControl
{
    public FolderView()
    {
        InitializeComponent();
        Control = this.FindControl<ContentControl>("Control");
    }

    private void InitializeComponent()
    {
        AvaloniaXamlLoader.Load(this);
    }

    private void ItemDoubleTapped(object? sender, RoutedEventArgs e)
    {
        if (sender is not Control control) return;
        if (control.DataContext is not FolderModel f) return;
        if (f.Location != null) 
            Control.Content = new DetailFolderView(){DataContext = Coding.Find(f.Location)};
    }
}